﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Linq.Expressions;
using Snake.Database;

namespace Snake
{
    /// <summary>
    /// session 是个什么东西，这个只可意会啊
    /// </summary>
    public interface ISession
    {
        
        void Open();
        
        //-----------------增-----------------
        void Save<T>(T entity);


        //-----------------删-----------------
        void Delete<T>(object primarykey) where T : class, new();
        void Delete<T>(IEnumerable<object> primarykeys);
        void Delete<T>(T entity);
        //-----------------改-----------------

        void Update<T>(T entity);
        void SaveOrUpdate<T>(T entity) where T : class, new();
        void SaveOrUpdate<T>(T entity, string parentIdColumnName, object parentId) where T : class, new();


        //---------------- 查------------------

        T Get<T>(object id);
        IQueryable<T> GetAll<T>();
       

       //-----------------执行SQL语句-----------


        TRef LoadReference<TSource, TRef>(TSource obj, Expression<Func<TSource, TRef>> expr) where TRef : class;
        IQueryable<TResult> LoadCollection<TSource, TResult>(TSource obj, Expression<Func<TSource, IEnumerable<TResult>>> expr) where TResult : class;
    }
}